﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SiGeSIB.GUI.Common;
using SiGeSIB.Data.Finances;
using SiGeSIB.Business.Common;

namespace SiGeSIB.GUI.Finances
{
#if DESIGN
	public partial class FEditOutcome : FormRedirector.FEditOutcome
#else
	public partial class FEditOutcome : FGenericEditor<Outcome>
#endif
	{
		public FEditOutcome()
			: this(EFormState.View, -1)
		{ }
		public FEditOutcome(EFormState initialState, int id)
			: base(initialState, id)
		{
			InitializeComponent();
			InitialState = initialState;
			CurrentId = id;
		}

		public Outcome EditedItem { get; private set; }
		public int CurrentId { get; set; }

		public override bool ConflictsWith(ConflictableForm form)
		{
			bool conflicts = false;

			if (form.GetType() == this.GetType())
			{
				// Só conflita se for inserção ou se for edição do mesmo elemento
				FEditOutcome fEdit = form as FEditOutcome;

				if (fEdit.InitialState == this.InitialState)
				{
					if (this.InitialState == EFormState.Edit)
						conflicts = true;
					else if (this.EditedItem != null && fEdit.EditedItem != null && this.EditedItem.Id == fEdit.EditedItem.Id)
						conflicts = true;
				}
			}

			return conflicts;
		}

		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad(e);

			base._LoadData();
		}

		protected override Outcome _LoadEntity(int id)
		{
			return null;
		}

		protected override void _FillEntity(Outcome entity)
		{
			throw new NotImplementedException();
		}

		protected override Outcome _BuildEntity()
		{
			throw new NotImplementedException();
		}

		protected override ExceptionsContainer _ValidateEntity(Outcome entity)
		{
			throw new NotImplementedException();
		}

		protected override int _SaveEntity(Outcome entity)
		{
			throw new NotImplementedException();
		}
	}
}
